<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
<script type="text/javascript">
	$(document).ready(function(){
		//메인 이미지 클릭시 팝업 열기
		$("#r_uploadFile").click(function(){
			window.open("${initParam.root }/recipe/imgPopup.jsp","","width=605,height=470,left=400,top=230");
		});
		
			if(${sessionScope.recipe1==null }){
				//$("#main_subject_text").val("요리 제목을 입력하세요.");
				//$("#main_content_text").val("요리에 대한 간단한 설명을 적어주세요");
				$("#main_subject_text").css("background-image","url(${initParam.root}/img/main/main-write1-title.gif)");
				$("#main_content_text").css("background-image","url(${initParam.root}/img/main/main-write1-comment.gif)");
			}else{
				$("#r_uploadFile").attr("src","${initParam.root }/upload/temp/${sessionScope.recipe1.r_img_new}");
				$("#main_subject_text").css("background-image","none");
				$("#main_content_text").css("background-image","none");
			}
			// 글을 쓸 때에 배경글자를 없에준다.
			$("#main_subject_text").focus(function(){
				$("#main_subject_text").css("background-image","none");
			});
			$("#main_content_text").focus(function(){
				$("#main_content_text").css("background-image","none");
			});
			
			
		$("#main_arrow_next").click(function(){
			if($("#main_subject_text").val()==""){
				alert("요리 제목을 입력하세요");
				return false;
			}
			if($("#main_content_text").val()==""){
				alert("요리에 대한 간단한 설명을 입력하세요");
				return false;
			}
			if($("#r_img_origin").val()==""){
				alert("사진을 등록하세요");
				return false;
			}
				$("#pForm_1").submit();
		});
		
		//처음 페이지 이기 때문에 alert창을 띄움
		$("#main_arrow_prev").click(function(){
			alert("처음 페이지 입니다");
		});
		// 작성 취소 버튼
		$("#main_cancle").click(function(){
			if(confirm("작성을 취소하시겠습니까?")){
				location.href="recipe.do?command=write_cancle";
			}
		});
	});

</script>
<div id="write_container">
<div id="main_page1"><img src="${initParam.root }/img/main/main-write-page1.gif"></div>
<div id="main_arrow_prev"><input type="image" src="${initParam.root }/img/main/main-write-prev.gif"></div>
<div id="main_arrow_next"><input type="image" src="${initParam.root }/img/main/main-write-next.gif"></div>
<div id="main_info_next"><img src="${initParam.root }/img/main/main-write-next-info.gif"></div>
<div id="main_cancle"><input type="image" src="${initParam.root }/img/main/main-write-cancle.gif"></div>
	<div id="main_write_form">
 		<form id="pForm_1" action="recipe.do" method="post">
 		<input type="hidden" name="command" value="writeNext">
 		<input type="hidden" name="page" value="2">
 		<input type="hidden" name="r_img_origin" id="r_img_origin" value="${sessionScope.recipe1.r_img_origin}">
 		<input type="hidden" name="r_img_new" id="r_img_new" value="${sessionScope.recipe1.r_img_new}">
 		<input type="hidden" name="r_img_thum" id="r_img_thum" value="${sessionScope.recipe1.r_img_thum}">
	 		<div id="main_title"><input type="text" id="main_subject_text" name="r_title" value="${sessionScope.recipe1.r_title}" /></div>
	 		<div id="main_img" align="center"><img src="${initParam.root }/img/main/main-write-img.jpg" name="r_uploadFile" id="r_uploadFile" style="cursor: pointer;"></div>
	 		<div id="main_comment"><textarea id="main_content_text" cols="75" rows="7" name="r_comment" >${sessionScope.recipe1.r_comment}</textarea></div>
 		</form>
 	</div>
</div>